
# base
copy-config:
	@touch ./config/config.js && cp ./config/config.js ./src/server/config.js

# dev

loader-builder:
	@./node_modules/loader-builder/bin/builder ./src/server/views ./src/server

build-config:
	@cp ./src/server/config.default.js ./src/server/config.js

dev-start: copy-config
	@npm start

# build-release:
# 	@PORT=80 WEBSITE_HOSTNAME=shuoriyu.cn NODE_ENV=production npm run build -- --release

# start-production: install loader-builder build-release
# 	@PORT=80 WEBSITE_HOSTNAME=shuoriyu.cn NODE_ENV=production ./node_modules/.bin/pm2 start ./build/server.js -i 0 --name "shuoriyu" --max-memory-restart 400M

# stop:
# 	@./node_modules/.bin/pm2 stop "shuoriyu"

# delete:
# 	@./node_modules/.bin/pm2 delete "shuoriyu"



# full-build-app-dev: install-cnpm
# 	@cp ./config/config.js src/server/config.js \
# 	  && make loader-builder \
# 	  && npm run build \
# 	  && cd ./images/myclub \
# 	  && ./builder

# build-app-dev:
# 	@cp ./config/config.js src/server/config.js \
# 	  && make loader-builder \
# 	  && npm run build \
# 	  && cd ./images/myclub \
# 	  && ./builder

# pro

pro-build-app: copy-config
	@NODE_ENV=production WEB_HOST=shuoriyu.cn WEB_PORT=80 yarn run build -- --release \
	  && cd ./images/myclub \
	  && ./builder

pro-start:
	@docker-compose up -d

pro-build-app-and-start:
	@make pro-build-app
	@make pro-start

pro-full-build-app-and-start:
	@make pro-full-build-app
	@make pro-start

pro-status:
	@docker-compose ps

pro-stop-app:
	@docker-compose stop app

pro-remove-app: pro-stop-app
	@docker-compose rm app \
	  && docker rmi xugy0926/my-club:1.0.0

pro-stop-all:
	@docker-compose down

pro-clean:
	@echo "Clean Docker images..."
	@docker ps -aqf status=exited | xargs docker rm \
	  && docker images -qf dangling=true | xargs docker rmi